package com.google.shoopinggoods;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import com.example.administrator.shoppinggoods.R;
import com.google.shoopinggoods.base.BaseActivity;
import com.google.shoopinggoods.fragment.LoginFragment;
import com.google.shoopinggoods.fragment.RegisterFragment;

/**
 * Created by Administrator on 2017/10/13.
 */
public class LoginActivity extends BaseActivity{

    @Override
    public int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    protected void setListener() {
    }

    @Override
    protected void initData() {
        showTitle(true,"登陆","注册");
        replaceFragment(new LoginFragment());
    }

    private boolean isShowLogin=true;
    private void replaceFragment(Fragment fragment) {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.login_container,fragment).commitAllowingStateLoss();
    }

    @Override
    public void onRightTitleClick() {
        super.onRightTitleClick();
        if (isShowLogin){
            showTitle(true,"注册","登陆");
            replaceFragment(new RegisterFragment());
        }else{
            showTitle(true,"登陆","注册");
            replaceFragment(new LoginFragment());
        }
        isShowLogin=!isShowLogin;
    }
}
